//
// Description: 800. 数组元素的目标和
// Created by Loading on 2022/5/25.
//

#include <bits/stdc++.h>

using namespace std;

constexpr int N = 1e5 + 10;

int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    int A[N], B[N];
    for (int i = 0; i < n; i ++ ) {
        cin >> A[i];
    }
    for (int i = 0; i < m; i ++ ) {
        cin >> B[i];
    }

    // 双指针，一个指向A的头，一个指向B的尾
    for (int i = 0, j = m - 1; i < n && j >= 0;) {
        if (A[i] + B[j] == x) {
            cout << i << ' ' << j << endl;
            break;
        } else if (A[i] + B[j] > x) {
            --j;
        } else {
            ++i;
        }
    }

    return 0;
}